import draw from 'try_2d'
let painter = draw(document.getElementById("cav"));
let obj = [
  { name: "A", value: 100 },
  { name: "B", value: 200 },
  { name: "C", value: 300 },
  { name: "D", value: 400 },
];
let startDeg = -0.5 * Math.PI;
let all = obj.reduce((n, item) => {
  return n + item.value;
}, 0);
let color = ["red", "blue", "yellow", "pink"];
for (let i = 0; i < obj.length; i++) {
  let deg = (obj[i].value / all) * 2 * Math.PI;
  painter.config({ fillStyle: color[i] });
  painter.fillArc(150, 150, 100, 130, startDeg, deg);
  startDeg += deg;
}
